package study.dyproxy.cglib.echo;

import lombok.extern.slf4j.Slf4j;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;

import java.lang.reflect.Method;

@Slf4j
public class EchoInterceptor implements MethodInterceptor {

    /**
     * @param sub         -Object:
     * @param method      -Method:
     * @param objects     -objects:
     * @param methodProxy -methodProxy:
     */
    @Override
    public Object intercept(Object sub,
                            Method method,
                            Object[] objects,
                            MethodProxy methodProxy) throws Throwable {
        log.info("执行前...");
        Object result = methodProxy.invokeSuper(sub, objects);
        log.info("执行后...");
        return result;
    }
}
